package com.gitee.wsl.ext.string


/**
 * Extracts from a string the char sequence that occurs before the given subsequence.
 *
 * @param str the string
 * @param seq the subsequence to search
 * @return the extracted substring, or the original string if the subsequence is not found
 */
fun String.beforeSequence(seq: String): String {
    val idx = indexOf(seq)
    if (idx == -1) {
        return this
    }
    return substring(0, idx)
}
